package com.company.app.validators;

import com.company.app.entities.Customer;

/**
 * The Class CustomerValidator.
 */
public class CustomerValidator {
	
	/** The Constant NAME_REQUIRED. */
	private static final String NAME_REQUIRED="The name is required.\n";
	
	/** The Constant EMAIL_REQUIRED. */
	private static final String EMAIL_REQUIRED="The email is required.\n";
	
	/** The Constant ADDRESS_REQUIRED. */
	private static final String ADDRESS_REQUIRED="The adress is required.\n";

	/**
	 * Valid customer.
	 *
	 * @param customer the customer
	 * @return the string
	 */
	public static String validCustomer(Customer customer){
		StringBuilder errorMsg = new StringBuilder();
		if ((customer.getName()==null || customer.getName().trim().isEmpty())){
			errorMsg.append(NAME_REQUIRED);
		}
		if (customer.getAddress()==null || customer.getAddress().trim().isEmpty()){
			errorMsg.append(ADDRESS_REQUIRED);
		}
		if (customer.getEmail()==null || customer.getEmail().trim().isEmpty()){
			errorMsg.append(EMAIL_REQUIRED);
		}
		return errorMsg.toString();
	}	

}
